package tech.aistar.corejava.day07.day05homework;

/**
 * @author success
 * @version 1.0
 * @description:本类用来演示:java.lang.ClassCastException - 运行时异常
 *                - 只有程序在运行的过程中才会显示这种异常.
 * @date 2019/7/23 0023
 */
public class TestAccount {
    public static void main(String[] args) {
        SavingAccount sa1 = new SavingAccount();
        Account acc1 = sa1;//多态 - 面向父类编程
        Account acc2 = new CreditAccount();

        //父类  对象 = new 子类();

        CreditAccount acc3 =(CreditAccount) new Account();//error

        CreditAccount acc33 =(CreditAccount)acc2;//ok

       // CreditAccount ca1 =  new Account();//error - 进行强制类型转换
        CreditAccount ca1 = (CreditAccount) new Account();//error - 进行强制类型转换
        SavingAccount acc4 = (SavingAccount)acc1;

        System.out.print(ca1 instanceof CreditAccount);
        System.out.print(acc2 instanceof CreditAccount);
        System.out.print(acc2 instanceof Account);
    }
}
